<h2>TEST of Migration</h2>
<?php


$hostname="localhost";
//$hostname1="127.0.0.1";
$username="root";
$password="";
$dbh1 = mysql_connect($hostname, $username, $password); 
$dbh2 = mysql_connect($hostname, $username, $password, true); 

mysql_select_db('madame_mdm_new', $dbh1);
mysql_select_db('gocartdbgocartdb_dump', $dbh2);
//Then to query database 1, do this:

$row_quey= mysql_query('Select id, facebook_id, email, password, name, dob, address , mobile, status, created FROM madame_mdm_new.users', $dbh1);
//and for database 2:
  $table= "<table>";
  	$table .= '<tr><td>id</td><td>facebook_id</td><td>email</td><td>password</td><td>name</td><td>dob</td><td>address</td><td>phone</td><td>status</td><td>created</td></tr>';
  
  
function randomPrefix($length) 
{ 
$random= "";
srand((double)microtime()*1000000);

$data = "ADE123IJKLMN67QRSTUVWXYZ"; 
$data .= "ZXYWVMNOPRSTUABCDEFG"; 
$data .= "0FGH45OP89";

for($i = 0; $i < $length; $i++) 
{ 
$random .= substr($data, (rand()%(strlen($data))), 1); 
}

return $random; 
}

while( $row= mysql_fetch_array($row_quey))
{
     //	 echo "<pre>";
	// print_r($row);	
	  $id = $row['id'];
	 // $fbuser = $row['facebook_id'];
	  $email = $row['email'];
	  $password = $row['password'];
      $firstname = $row['name'];
	  $dateofBirth = $row['dob'];
	  $default_billing_address = $row['address'];
	  $phone = $row['mobile'];
	  $active = $row['status'];
	  $confirmed = $row['created'];
	//echo "<hr>";
	  
	//  $slug = strtolower(str_replace(" ", "", "$product_name"));
//	  $route_id="route_id";
	$table .= '<tr><td>'.$id.'</td><td>'.'</td><td>'.$email.'</td><td>'.$password.'</td><td>'.$firstname.'</td><td>'.$dateofBirth.'</td><td>'.$default_billing_address.'</td><td>'.$phone.'</td><td>'.$active.'</td><td>'.$confirmed.'</td></tr>';
	//echo  $id ."|".$product_name."";
	//  $r_id= "cart/product/$id";
//echo $check_route="Select * from gc_routes where route='".$r_id."'";
//$row_quey_route = mysql_query($check_route, $dbh2);
 //  $num_rows= mysql_num_rows($row_quey_route);
// echo "<br>";
//	if($num_rows==0)
//	{
//		echo  $sql_route = "INSERT INTO `gc_routes` (`id`, `slug`, `route`) VALUES (NULL, '$slug', 'cart/product/$id')";
//		 $row_quey_process = mysql_query($sql_route, $dbh2);
//		 $last_route_id =mysql_insert_id();
//		//$last_route_id ="";
//	}else
//	{
//	echo $id."Already present Route  ";
//
//	}
	
	$check_products= "Select * from gc_customers where id=$id";
    $row_quey_products = mysql_query($check_products, $dbh2);
    $num_rows_products= mysql_num_rows($row_quey_products);
	$sku = randomPrefix(6); 
	if($num_rows_products==0)
	{
	 echo  $sql1 = "INSERT INTO `gocartdbgocartdb_dump`.`gc_customers`
	  (`id`, `email`, `password`, `firstname`, `dateofBirth`, `default_billing_address`, `phone`, `active`, `confirmed`) VALUES 
	  ($id,  '$email', '$password', '$firstname', '$dateofBirth ', '$default_billing_address', '$phone', '$active', '$confirmed');";
	  echo "<br>";
	 $row_quey_category = mysql_query($sql1, $dbh2);
	}else
	{
	echo $id."Already present user ";
	}
	
}
    $table .= "</table>";

?>

